package com.synnex.mobile.servier.core.survey.bo;

import com.synnex.mobile.generic.core.util.ObjectUtil;
import com.synnex.mobile.servier.core.survey.dto.AnswerItem;
import com.synnex.mobile.servier.core.survey.dto.Questionnaire;
import com.synnex.mobile.servier.core.survey.dto.Survey;

import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-8-8
 * To change this template use File | Settings | File Templates.
 */
public class SurveyBo {

    private Integer id;

    private Integer questionnaireId;
    private String title;

    private String titleOther;

    private String type;

    private Integer seq;

    private String require;

    private Date entryDate;

    private Date updateDate;

    private String[] aseq;
    private String[] atitle;
    private String[] aid;

//    private Set<AnswerItem> answerItems= new TreeSet<AnswerItem>();

    private   List<AnswerItemBo> answerItems;

    private List<String> askInfoList;

    private  Integer surveyCount;

    public String[] getAid() {
        return aid;
    }

    public void setAid(String[] aid) {
        this.aid = aid;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getQuestionnaireId() {
        return questionnaireId;
    }

    public void setQuestionnaireId(Integer questionnaireId) {
        this.questionnaireId = questionnaireId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Integer getSeq() {
        return seq;
    }

    public void setSeq(Integer seq) {
        this.seq = seq;
    }

    public Date getEntryDate() {
        return entryDate;
    }

    public void setEntryDate(Date entryDate) {
        this.entryDate = entryDate;
    }

    public String getRequire() {
        return require;
    }

    public void setRequire(String require) {
        this.require = require;
    }

    public String getTitleOther() {
        return titleOther;
    }

    public void setTitleOther(String titleOther) {
        this.titleOther = titleOther;
    }

    public Date getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    public List<AnswerItemBo> getAnswerItems() {
        return answerItems;
    }

    public void setAnswerItems(List<AnswerItemBo> answerItems) {
        this.answerItems = answerItems;
    }

    public List<String> getAskInfoList() {
        return askInfoList;
    }


    public void setAskInfoList(List<String> askInfoList) {
        this.askInfoList = askInfoList;
    }
    //    public Set<AnswerItem> getAnswerItems() {
//        return answerItems;
//    }
//
//    public void setAnswerItems(Set<AnswerItem> answerItems) {
//        this.answerItems = answerItems;
//    }

    public static SurveyBo  createInstance(Survey survey){

         List<AnswerItemBo> answerItemList = new ArrayList<AnswerItemBo>();
        if(survey!=null){
            SurveyBo bo =  ObjectUtil.copyProperties(survey, SurveyBo.class);
            if(survey != null && survey.getAnswerItems()!=null&& !survey.getAnswerItems().isEmpty()){
                for(AnswerItem answerItem:survey.getAnswerItems())  {
                    answerItemList.add(AnswerItemBo.createInstance(answerItem)) ;
                }
                 Collections.sort(answerItemList);
            }
              bo.setAnswerItems(answerItemList);

            return  bo;
        }else{
            return new SurveyBo();
        }
    }

    public static List<SurveyBo> createInstance(List<Survey> datas){

        List<SurveyBo> questionnaireBos = new ArrayList<SurveyBo>();

        if (datas != null) {
            for (Survey data : datas) {
                questionnaireBos.add(createInstance(data));
            }
        }
        return questionnaireBos;
    }

    public String[] getAseq() {
        return aseq;
    }

    public void setAseq(String[] aseq) {
        this.aseq = aseq;
    }

    public String[] getAtitle() {
        return atitle;
    }

    public void setAtitle(String[] atitle) {
        this.atitle = atitle;
    }

    public Integer getSurveyCount() {
        return surveyCount;
    }

    public void setSurveyCount(Integer surveyCount) {
        this.surveyCount = surveyCount;
    }
}
